<template>
  <div>
    <button v-for="item in cityList" :key="item" @click="fn(item)">
      {{ item }}
    </button>
  </div>
</template>

<script>
import { mapMutations } from "vuex";

export default {
  data() {
    return {
      cityList: ["郑州", "杭州", "北京", "广州"],
    };
  },
  methods: {
    ...mapMutations(["changeCity"]),
    fn(item) {
      console.log(item);
      this.changeCity({ name: item });
      this.$router.go(-1);
    },
  },
};
</script>
